//
//  JwLanguager.h
//  JwPack
//
//  Created by 陈警卫 on 2024-08-07.
//

#import <Foundation/Foundation.h>

/// 切换语言 通知key
#define kJwLanguagerNotiKey @"kJwLanguagerNotiKey"

/// 获取多语言值
#define kJwLocalizedString(key) [[JwLanguager shared] valueLanguageWithKey:key]
/// 获取多语言值
#define kJwLocalizedTableString(key, table) [[JwLanguager shared] valueLanguageWithKey:key table:table]

/// 多语言单例
#define kJwLanguager [JwLanguager shared]

/**
 ex.
 1. 初始化单例
    [JwLanguager shared]
 
 2. 自建JwLocalizable.strings文件
    设置 kJwLanguager.languageName = @"JwLocalizable";
    设置 kJwLanguager.languageCans = @[@"en", @"zh-Hans", @"fr"];
 
 3. 设置当前语言
    [kJwLanguager setupCurrentLanguage:@"en"];
    会发送 kJwLanguagerNotiKey 通知
 
 4. 初始化后
    设置 kJwLanguager.enable = NO; 时
    默认使用系统多语言 NSLocalizedString
    多语言文件名为 Localizable.strings
 */

NS_ASSUME_NONNULL_BEGIN

@interface JwLanguager : NSObject

/// 单例
+ (JwLanguager *)shared;

/// bundle内自设多语言文件名称
@property (nonatomic, strong) NSString *languageName;

/// app内支持的多语言数组 ex. @[@"en", @"zh-Hans", @"fr"];
@property (nonatomic, strong) NSArray *languageCans;

/// 是否启用JwLanguager管理 默认YES (NO时 多语言为NSLocalizedString)
@property (nonatomic, assign) BOOL enable;

/// 是否启用寻找英语en 默认YES (key在当前语言文件找不到时 会去查询en文件)
@property (nonatomic, assign) BOOL searchEn;

/// 当前语言 默认系统语言
@property (nonatomic, strong, readonly) NSString *currentLanguage;

/// 设置当前语言
- (void)setupCurrentLanguage:(NSString *)language;

/// 获取当前语言对应的值
- (NSString *)valueLanguageWithKey:(NSString *)key;

/// 获取当前语言对应的值
- (NSString *)valueLanguageWithKey:(NSString *)key table:(nullable NSString *)table;


@end

NS_ASSUME_NONNULL_END
